#ifndef QxColorDelegate_H
#define QxColorDelegate_H

#include "QxColorDelegate_global.h"
#include <QItemDelegate>

class MYDELEGATE_EXPORT QxColorDelegate : public QItemDelegate
{
	Q_OBJECT

public:
	QxColorDelegate(QObject *parent = 0);
	~QxColorDelegate();

	virtual QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
	virtual void	setEditorData ( QWidget * editor, const QModelIndex & index ) const;
	virtual void	setModelData ( QWidget * editor, QAbstractItemModel * model, const QModelIndex & index ) const;
	virtual void	updateEditorGeometry ( QWidget * editor, const QStyleOptionViewItem & option, const QModelIndex & index ) const;

private slots:
	void commitDataAndCloseEditor();
private:
	QString getNameByData(int data) const;
	bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index);
	bool eventFilter(QObject *object, QEvent *event);
};

#endif // QxColorDelegate_H
